home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 2 / AACD 2.iso / AACD / Programming / fpc / compiler / systems.pas < prev    next >
Pascal/Delphi Source File  |  1998-09-24  |  16KB  |  551 lines

  1. {
  2.     $Id: systems.pas,v 1.2.2.3 1998/08/18 13:40:10 carl Exp $
  3.     Copyright (C) 1995,97 by Florian Klaempfl
  4.  
  5.     This unit contains informations about the target systems supported
  6.     (these are not processor specific)
  7.  
  8.     This program is free software; you can redistribute it and/or modify
  9.     it under the terms of the GNU General Public License as published by
  10.     the Free Software Foundation; either version 2 of the License, or
  11.     (at your option) any later version.
  12.  
  13.     This program is distributed in the hope that it will be useful,
  14.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.     GNU General Public License for more details.
  17.  
  18.     You should have received a copy of the GNU General Public License
  19.     along with this program; if not, write to the Free Software
  20.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22.  ****************************************************************************
  23. }
  24. unit systems;
  25.  
  26.   interface
  27.  
  28.     type
  29.        { target operanting system }
  30.        ttarget = (target_GO32V1,target_OS2,target_LINUX,
  31.                   target_WIN32,target_GO32V2,
  32.                   target_Amiga,target_Atari,target_Mac68k,
  33.                   target_PalmOS);
  34.  
  35.        tendian = (endian_little,en_big_endian);
  36.  
  37.  
  38.        ttargetinfo = record
  39.           target : ttarget;
  40.           target_name : string[30];
  41.           short_name : string[8];
  42.           unit_env : string[20];
  43.           system_unit : string[8];
  44.           exeext,
  45.           objext,
  46.           dllext,
  47.           unitext,
  48.           libext,
  49.           asmext,
  50.           sourceext,
  51.           pasext  : string[4];
  52.           newline : string[3];
  53.           labelprefix : string[2];
  54.           Cprefix : string[2];
  55.           use_function_relative_addresses : boolean;
  56.           endian : tendian;
  57.        end;
  58.  
  59.        tsourceinfo = record
  60.           source:ttarget;
  61.           source_name:string[30];
  62.           exeext,
  63.           scriptext : string[4];
  64.           endian : tendian;
  65.        end;
  66.  
  67.     var
  68.        source_info : tsourceinfo;
  69.        target_info : ttargetinfo;
  70.  
  71.     function set_string_target(const s : string) : boolean;
  72.  
  73.   implementation
  74.  
  75.     const
  76.        target_infos : array[ttarget] of ttargetinfo = (
  77.           (
  78.             target : target_GO32V1;
  79.             target_name : 'GO32 V1 DOS extender';
  80.             short_name : 'GO32V1';
  81.             unit_env : 'GO32V1UNITS';
  82.             system_unit : 'SYSTEM';
  83.             exeext : '';
  84.             objext : '.O1';
  85.             dllext : '.DLL';
  86.             unitext : '.PP1';
  87.             libext : '.PPL';
  88.             asmext : '.S1';
  89.             sourceext : '.PP';
  90.             pasext : '.PAS';
  91.             newline : #13#10;
  92.             labelprefix : '.L';
  93.             Cprefix : '_';
  94.             use_function_relative_addresses : true;
  95.             endian : endian_little
  96.           ),
  97.           (
  98.             target : target_OS2;
  99.             target_name : 'OS/2 (32 bit)';
  100.             short_name : 'OS2';
  101.             unit_env : 'OS2UNITS';
  102.             system_unit : 'SYSOS2';
  103.             exeext : '.exe';
  104.             objext : '.oo2';
  105.             dllext : '.dll';
  106.             unitext : '.ppo';
  107.             libext : '.ppl';
  108.             asmext : '.so2';
  109.             sourceext : '.pas';
  110.             pasext : '.pp';
  111.             newline : #13#10;
  112.             labelprefix : 'L';
  113.             Cprefix : '_'; {???}
  114.             use_function_relative_addresses : true;
  115.             endian : endian_little
  116.           ),
  117.           (
  118.             target : target_LINUX;
  119.             target_name : 'Linux';
  120.             short_name : 'LINUX';
  121.             unit_env : 'LINUXUNITS';
  122.             system_unit : 'syslinux';
  123.             exeext : '';
  124.             objext : '.o';
  125.             dllext : '.so';
  126.             unitext : '.ppu';
  127.             libext : '.ppl';
  128.             asmext : '.s';
  129.             sourceext : '.pp';
  130.             pasext : '.pas';
  131.             newline : #10;
  132.             labelprefix : '.L';
  133.             Cprefix : '';
  134.             use_function_relative_addresses : true;
  135.             endian : endian_little
  136.           ),
  137.           (
  138.             target : target_WIN32;
  139.             target_name : 'Win32';
  140.             short_name : 'WIN32';
  141.             unit_env : 'WIN32UNITS';
  142.             system_unit : 'SYSWIN32';
  143.             exeext : '.exe';
  144.             objext : '.o';
  145.             dllext : '.dll';
  146.             unitext : '.ppw';
  147.             libext : '.ppl';
  148.             asmext : '.s';
  149.             sourceext : '.pp';
  150.             pasext : '.pas';
  151.             newline : #13#10;
  152.             labelprefix : '.L';
  153.             Cprefix : '_'; {???}
  154.             use_function_relative_addresses : true; {????}
  155.             endian : endian_little
  156.           ),
  157.           (
  158.             target : target_GO32V2;
  159.             target_name : 'GO32 V2.0 DOS extender';
  160.             short_name : 'GO32V2';
  161.             unit_env : 'GO32V2UNITS';
  162.             system_unit : 'SYSTEM';
  163.             exeext : '.EXE';
  164.             objext : '.O';
  165.             dllext : '.DLL';
  166.             unitext : '.PPU';
  167.             libext : '.PPL';
  168.             asmext : '.S';
  169.             sourceext : '.PP';
  170.             pasext : '.PAS';
  171.             newline : #13#10;
  172.             labelprefix : '.L';
  173.             Cprefix : '_'; {???}
  174.             use_function_relative_addresses : true;
  175.             endian : endian_little
  176.           ),
  177.           (
  178.             target : target_Amiga;
  179.             target_name : 'Commodore Amiga';
  180.             short_name : 'AMIGA';
  181.             unit_env : '';
  182.             system_unit : 'sysamiga';  { case sensitive }
  183.             exeext : '';
  184.             objext : '.o';
  185.             dllext : '.library';
  186.             unitext : '.ppa';
  187.             libext : '.ppl';
  188.             asmext : '.asm';
  189.             sourceext : '.pp';
  190.             pasext : '.pas';
  191.             newline : #10;
  192.             labelprefix : '.L';
  193.             Cprefix : '_'; {???}
  194.             use_function_relative_addresses : true;
  195.             endian : endian_little
  196.           ),
  197.           (
  198.             target : target_Atari;
  199.             target_name : 'Atari ST/STE';
  200.             short_name : 'ATARI';
  201.             unit_env : '';
  202.             system_unit : 'SYSATARI';
  203.             exeext : '.ttp';
  204.             objext : '.o';
  205.             dllext : '.dll';
  206.             unitext : '.PPT';
  207.             libext : '.PPL';
  208.             asmext : '.s';
  209.             sourceext : '.pp';
  210.             pasext : '.pas';
  211.             newline : #13#10;
  212.             labelprefix : '.L';
  213.             Cprefix : '_'; {???}
  214.             use_function_relative_addresses : true;
  215.             endian : endian_little
  216.           ),
  217.           (
  218.             target : target_Mac68k;
  219.             target_name : 'Macintosh m68k';
  220.             short_name : 'MAC OS';
  221.             unit_env : '';
  222.             system_unit : 'sysmac';    { case sensitive }
  223.             exeext : '';
  224.             objext : '.o';
  225.             dllext : '.dll';
  226.             unitext : '.ppm';
  227.             libext : '.ppl';
  228.             asmext : '.asm';
  229.             sourceext : '.pp';
  230.             pasext : '.pas';
  231.             newline : #13;
  232.             labelprefix : '__L';{ only ascii A..Z,a..z or _ allowed as first }
  233.             Cprefix : ''; {???}
  234.             use_function_relative_addresses : true;
  235.             endian : endian_little
  236.           ),
  237.           (
  238.             target : target_PalmOS;
  239.             target_name : 'PalmOS';
  240.             short_name : 'PALMOS';
  241.             unit_env : '';
  242.             system_unit : 'SYSPALM';
  243.             exeext : '.prc';
  244.             objext : '.o';
  245.             dllext : '.dll';
  246.             unitext : '.PPU';
  247.             libext : '.PPL';
  248.             asmext : '.s';
  249.             sourceext : '.pp';
  250.             pasext : '.pas';
  251.             newline : #13#10;
  252.             labelprefix : '.L';
  253.             Cprefix : '';
  254.             use_function_relative_addresses : true;
  255.             endian : endian_little
  256.           )
  257.        );
  258.  
  259.        source_infos : array[ttarget] of tsourceinfo = (
  260.           (
  261.             source : target_GO32V1;
  262.             source_name : 'GO32 V1 DOS extender';
  263.             exeext : '.EXE';
  264.             scriptext : '.BAT';
  265.             endian : endian_little
  266.           ),
  267.           (
  268.             source : target_OS2;
  269.             source_name : 'OS/2 (32 bit)';
  270.             exeext : '.EXE';
  271.             scriptext : '.CMD';
  272.             endian : endian_little
  273.           ),
  274.           (
  275.             source : target_LINUX;
  276.             source_name : 'Linux';
  277.             exeext : '';
  278.             scriptext : '.sh';
  279.             endian : endian_little
  280.           ),
  281.           (
  282.             source : target_WIN32;
  283.             source_name : 'Win32';
  284.             exeext : '.EXE';
  285.             scriptext : '.BAT';
  286.             endian : endian_little
  287.           ),
  288.           (
  289.             source : target_GO32V2;
  290.             source_name : 'GO32 V2.0 DOS extender';
  291.             exeext : '.EXE';
  292.             scriptext : '.BAT';
  293.             endian : endian_little
  294.           ),
  295.           (
  296.             source : target_Amiga;
  297.             source_name : 'Commodore Amiga';
  298.             exeext : '';
  299.             scriptext : '';
  300.             endian : en_big_endian
  301.           ),
  302.           (
  303.             source : target_Atari;
  304.             source_name : 'Atari ST/STE';
  305.             exeext : '.ttp';
  306.             scriptext : '';
  307.             endian : en_big_endian
  308.           ),
  309.           (
  310.             source : target_Mac68k;
  311.             source_name : 'Macintosh m68k';
  312.             exeext : '';
  313.             scriptext : '';
  314.             endian : en_big_endian
  315.           ),
  316.           (
  317.             source : target_PalmOS;
  318.             source_name : 'PalmOS';
  319.             exeext : '.prc';
  320.             scriptext : '';
  321.             endian : en_big_endian
  322.           )
  323.        );
  324.  
  325.     procedure set_target(t : ttarget);
  326.  
  327.       begin
  328.          target_info:=target_infos[t];
  329.       end;
  330.  
  331.     function set_string_target(const s : string) : boolean;
  332.  
  333.       var
  334.          t : ttarget;
  335.  
  336.       begin
  337.          set_string_target:=false;
  338.          for t:=target_GO32V1 to target_PalmOS do
  339.            if target_infos[t].short_name=s then
  340.              begin
  341.                 set_string_target:=true;
  342.                 set_target(t);
  343.              end;
  344.       end;
  345.  
  346.     procedure default_os(t:ttarget);
  347.  
  348.       begin
  349.          set_target(t);
  350.          source_info:=source_infos[t];
  351.       end;
  352.  
  353. begin
  354. {$ifdef tp}
  355.   default_os(target_GO32V2);
  356. {$else}
  357.   {$ifdef DOS}
  358.     default_os(target_GO32V1);
  359.   {$endif}
  360.   {$ifdef GO32V1}
  361.     default_os(target_GO32V1);
  362.   {$endif}
  363.   {$ifdef GO32V2}
  364.     default_os(target_GO32V2);
  365.   {$endif}
  366.   {$ifdef OS2}
  367.     default_os(target_OS2);
  368.   {$endif}
  369.   {$ifdef LINUX}
  370.     default_os(target_LINUX);
  371.   {$endif}
  372.   {$ifdef WIN32}
  373.     default_os(target_WIN32);
  374.   {$endif}
  375.   {$ifdef AMIGA}
  376.     default_os(target_AMIGA);
  377.   {$endif}
  378.   {$ifdef ATARI}
  379.     default_os(target_ATARI);
  380.   {$endif}
  381.   {$ifdef MACOS}
  382.     default_os(target_MAC68k);
  383.   {$endif}
  384. {$endif}
  385. end.
  386. {
  387.   $Log: systems.pas,v $
  388.   Revision 1.2.2.3  1998/08/18 13:40:10  carl
  389.     + CPrefix for Amiga and Atari targts
  390.  
  391.   Revision 1.2.2.2  1998/08/13 17:41:33  florian
  392.     + some stuff for the PalmOS added
  393.  
  394.   Revision 1.2.2.1  1998/08/13 13:36:14  carl
  395.     * Amiga and Mac EOLN are now correct and sure
  396.  
  397.   Revision 1.2  1998/03/30 15:53:01  florian
  398.     * last changes before release:
  399.        - gdb fixed
  400.        - ratti386 warning removed (about unset function result)
  401.  
  402.   Revision 1.1.1.1  1998/03/25 11:18:15  root
  403.   * Restored version
  404.  
  405.   Revision 1.33  1998/03/10 23:48:37  florian
  406.     * a couple of bug fixes to get the compiler with -OGaxz compiler, sadly
  407.       enough, it doesn't run
  408.  
  409.   Revision 1.32  1998/03/10 16:27:46  pierre
  410.     * better line info in stabs debug
  411.     * symtabletype and lexlevel separated into two fields of tsymtable
  412.     + ifdef MAKELIB for direct library output, not complete
  413.     + ifdef CHAINPROCSYMS for overloaded seach across units, not fully
  414.       working
  415.     + ifdef TESTFUNCRET for setting func result in underfunction, not
  416.       working
  417.  
  418.   Revision 1.31  1998/03/10 01:17:29  peter
  419.     * all files have the same header
  420.     * messages are fully implemented, EXTDEBUG uses Comment()
  421.     + AG... files for the Assembler generation
  422.  
  423.   Revision 1.30  1998/03/05 22:43:53  florian
  424.     * some win32 support stuff added
  425.  
  426.   Revision 1.29  1998/03/02 22:04:36  carl
  427.     + Added mac line break
  428.  
  429.   Revision 1.28  1998/03/02 13:38:51  peter
  430.     + importlib object
  431.     * doesn't crash on a systemunit anymore
  432.     * updated makefile and depend
  433.  
  434.   Revision 1.25  1998/02/28 00:20:34  florian
  435.     * more changes to get import libs for Win32 working
  436.  
  437.   Revision 1.24  1998/02/27 22:28:01  florian
  438.     + win_targ unit
  439.     + support of sections
  440.     + new asmlists: sections, exports and resource
  441.  
  442.   Revision 1.23  1998/02/27 21:24:20  florian
  443.     * dll support changed (dll name can be also a string contants)
  444.  
  445.   Revision 1.22  1998/02/23 02:55:08  carl
  446.     + added correct extension to AMIGA libext
  447.  
  448.   Revision 1.21  1998/02/22 23:03:39  peter
  449.     * renamed msource->mainsource and name->unitname
  450.     * optimized filename handling, filename is not seperate anymore with
  451.       path+name+ext, this saves stackspace and a lot of fsplit()'s
  452.     * recompiling of some units in libraries fixed
  453.     * shared libraries are working again
  454.     + $LINKLIB <lib> to support automatic linking to libraries
  455.     + libraries are saved/read from the ppufile, also allows more libraries
  456.       per ppufile
  457.  
  458.   Revision 1.20  1998/02/18 14:14:44  michael
  459.   * removed entries for dos_targ and lin_targ
  460.  
  461.   Revision 1.19  1998/02/17 21:21:05  peter
  462.     + Script unit
  463.     + __EXIT is called again to exit a program
  464.     - target_info.link/assembler calls
  465.     * linking works again for dos
  466.     * optimized a few filehandling functions
  467.     * fixed stabs generation for procedures
  468.  
  469.   Revision 1.18  1998/02/14 01:45:35  peter
  470.     * more fixes
  471.     - pmode target is removed
  472.     - search_as_ld is removed, this is done in the link.pas/assemble.pas
  473.     + findexe() to search for an executable (linker,assembler,binder)
  474.  
  475.   Revision 1.17  1998/02/13 22:26:45  peter
  476.     * fixed a few SigSegv's
  477.     * INIT$$ was not written for linux!
  478.     * assembling and linking works again for linux and dos
  479.     + assembler object, only attasmi3 supported yet
  480.     * restore pp.pas with AddPath etc.
  481.  
  482.   Revision 1.16  1998/02/13 10:35:50  daniel
  483.   * Made Motorola version compilable.
  484.   * Fixed optimizer
  485.  
  486.   Revision 1.15  1998/02/12 17:19:32  florian
  487.     * fixed to get remake3 work, but needs additional fixes (output, I don't like
  488.       also that aktswitches isn't a pointer)
  489.  
  490.   Revision 1.14  1998/02/12 11:50:50  daniel
  491.   Yes! Finally! After three retries, my patch!
  492.  
  493.   Changes:
  494.  
  495.   Complete rewrite of psub.pas.
  496.   Added support for DLL's.
  497.   Compiler requires less memory.
  498.   Platform units for each platform.
  499.  
  500.   Revision 1.11  1998/01/26 16:42:01  daniel
  501.   * Reversed source_ext and pas_ext for OS/2 target. The .pas extension is
  502.   recognized by the Workplace Shell of OS/2, the .pp is not.
  503.  
  504.   Revision 1.10  1998/01/26 13:35:33  florian
  505.     * adapted to work with TP
  506.  
  507.   Revision 1.9  1998/01/25 18:45:50  peter
  508.     + Search for as and ld at startup
  509.     + source_info works the same as target_info
  510.     + externlink allows only external linking
  511.  
  512.   Revision 1.8  1998/01/22 08:57:55  peter
  513.     + added target_info.pasext and target_info.libext
  514.  
  515.   Revision 1.7  1998/01/09 19:44:09  carl
  516.     * labels for mac68k target now use the MPW correct syntax
  517.  
  518.   Revision 1.6  1997/12/12 13:28:42  florian
  519.   + version 0.99.0
  520.   * all WASM options changed into MASM
  521.   + -O2 for Pentium II optimizations
  522.  
  523.   Revision 1.5  1997/12/09 14:12:21  carl
  524.   + added planned m68k systems, and fixed some problems in amiga info.
  525.  
  526.   Revision 1.4  1997/12/08 11:53:49  pierre
  527.       reverted to old version of systems.pas,
  528.       Daniel's version is not compilable due to the bug (corrected) of
  529.       mil value for a procvar const !!
  530.  
  531.   Revision 1.1.1.1  1997/11/27 08:33:02  michael
  532.   FPC Compiler CVS start
  533.  
  534.   Pre-CVS log:
  535.  
  536.     CEC    Carl-Eric Codere
  537.     FK     Florian Klaempfl
  538.     +      feature added
  539.     -      removed
  540.     *      bug fixed or changed
  541.  
  542.   History:
  543.       15th october 1996:
  544.          + ttargetinfo.newline added (FK)
  545.       19th september 1997:
  546.          * the suffix of GO32V1 units is now PP1 (FK)
  547.        8th october 1997:
  548.          + target amiga added for tests, unit should divided
  549.            into sysi386 and sysm68k (FK)
  550. }
  551.